/*
 * VersionFrame.java
 *
 * Displays a JVM version error message. This is in English only as resources
 * have not been loaded.
 *
 * @author Guy Wittig
 * @version 18-Jun-2006
 *
 *   This program is part of MV-Plan
 *   Copywrite 2006 Guy Wittig
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of 
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   The GNU General Public License can be read at http://www.gnu.org/licenses/licenses.html
 */

package mvplan.gui.text;

import mvplan.util.BrowserLauncher;

public class VersionFrame extends javax.swing.JFrame {
    
    private static String JAVA_URL = "http://www.java.com/en/download/manual.jsp";
    private java.awt.Cursor oldCursor;
    
    /** Creates new form versionFrame */
    public VersionFrame(String found, String min) {
        initComponents();
        versionLabel.setText("You have Java version: "+found);
        versionL1.setText("This application requires Java Runtime version "+min+" or later.");
        versionL2.setText("Please download the Java Standard Edition Runtime from");
        versionLink.setText(
            "<html><p><font color=\"#0000FF\"><u>http://java.sun.com</u></font></p>");
        pack();
        setDefaultCloseOperation(javax.swing.JFrame.DISPOSE_ON_CLOSE);
        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize(); 
        setLocation((screenSize.width-getWidth())/2,(screenSize.height-getHeight())/2);    
        oldCursor=getCursor();
        setDefaultLookAndFeelDecorated(false);
        setVisible(true);
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel2 = new javax.swing.JPanel();
        versionLabel = new javax.swing.JLabel();
        versionL1 = new javax.swing.JLabel();
        jPanel3 = new javax.swing.JPanel();
        versionL2 = new javax.swing.JLabel();
        versionLink = new javax.swing.JLabel();
        buttonPanel = new javax.swing.JPanel();
        exitButton = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Error");
        setResizable(false);
        getContentPane().setLayout(new java.awt.FlowLayout());

        jPanel2.setBorder(javax.swing.BorderFactory.createEmptyBorder(10, 10, 10, 10));
        jPanel2.setLayout(new java.awt.GridLayout(4, 1));

        versionLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        versionLabel.setText("<VERSION>");
        jPanel2.add(versionLabel);

        versionL1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        versionL1.setText("<REQUIRES>");
        jPanel2.add(versionL1);

        versionL2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        versionL2.setText("<DOWNLOAD>");
        jPanel3.add(versionL2);

        versionLink.setForeground(java.awt.Color.blue);
        versionLink.setText("http://java.sun.com");
        versionLink.setToolTipText("");
        versionLink.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                versionLinkMouseClicked(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                versionLinkMouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                versionLinkMouseExited(evt);
            }
        });
        jPanel3.add(versionLink);

        jPanel2.add(jPanel3);

        exitButton.setText("Exit");
        exitButton.setToolTipText("Exit Mvplan");
        exitButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                exitButtonActionPerformed(evt);
            }
        });
        buttonPanel.add(exitButton);

        jPanel2.add(buttonPanel);

        getContentPane().add(jPanel2);
    }// </editor-fold>//GEN-END:initComponents

    private void versionLinkMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_versionLinkMouseExited
        setCursor(oldCursor);
    }//GEN-LAST:event_versionLinkMouseExited

    private void versionLinkMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_versionLinkMouseEntered
        java.awt.Cursor handCursor = new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR);
        setCursor(handCursor);
    }//GEN-LAST:event_versionLinkMouseEntered

    private void versionLinkMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_versionLinkMouseClicked
        BrowserLauncher.openURL(JAVA_URL);
    }//GEN-LAST:event_versionLinkMouseClicked

    private void exitButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exitButtonActionPerformed
        setVisible(false);
        dispose();
        System.exit(0);
    }//GEN-LAST:event_exitButtonActionPerformed
    

    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel buttonPanel;
    private javax.swing.JButton exitButton;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JLabel versionL1;
    private javax.swing.JLabel versionL2;
    private javax.swing.JLabel versionLabel;
    private javax.swing.JLabel versionLink;
    // End of variables declaration//GEN-END:variables
    
}
